package com.guanyong.admin.controllers.page;

import com.guanyong.model.SubjectModel;
import com.guanyong.services.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by mxk on 2017/9/22.
 */
@Controller
@RequestMapping("/page/subject")
public class SubjectPage  extends baseController{

    @Autowired
    SubjectService subjectService;

    @RequestMapping({"/list"})
    String subjectList(HttpServletRequest request) {
        return  "/subject/list";
    }

    @RequestMapping({"/add"})
    String addsubject(HttpServletRequest request) {
        return  "/subject/add";
    }

    @RequestMapping({"/update"})
    String updatesubject(Model model, HttpServletRequest request) {


        String fid=request.getParameter("fid");

        SubjectModel subjectModel =subjectService.GetSubjectByIdModel(fid);
        if (subjectModel!=null){
            model.addAttribute("subjectmodel",subjectModel);
            return  "/subject/update";
        }
        else{
            return "errorPage/500";
        }

    }
}
